From: Nick Cameron Date: Mon, 10 Jul 2017 02:09:56 +0000 (+1200) Subject: Add a way to force a unit of work to always be rebuilt X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~8^2~12^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=c7b2df1fbccfe9fbe459fb94d4382f3e7c4bf8b0;p=cargo.git Add a way to force a unit of work to always be rebuilt --- diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 6e83c04a9..34601913a 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -83,6 +83,12 @@ pub trait Executor: Send + Sync + 'static { cmd.exec_with_streaming(handle_stdout, handle_stderr, false)?; Ok(()) } + + /// Queried when queuing each unit of work. If it returns true, then the + /// unit will always be rebuilt, independent of whether it needs to be. + fn force_rebuild(&self, _unit: &Unit) -> bool { + false + } } /// A DefaultExecutor calls rustc without doing anything else. It is Cargo's @@ -230,7 +236,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, // we run these targets later, so this is just a noop for now (Work::new(|_| Ok(())), Work::new(|_| Ok(())), Freshness::Fresh) } else { - let (freshness, dirty, fresh) = fingerprint::prepare_target(cx, unit)?; + let (mut freshness, dirty, fresh) = fingerprint::prepare_target(cx, unit)?; let work = if unit.profile.doc { rustdoc(cx, unit)? } else { @@ -239,6 +245,11 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, // Need to link targets on both the dirty and fresh let dirty = work.then(link_targets(cx, unit, false)?).then(dirty); let fresh = link_targets(cx, unit, true)?.then(fresh); + + if exec.force_rebuild(unit) { + freshness = Freshness::Dirty; + } + (dirty, fresh, freshness) }; jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness)?;